home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / Selection ƒ 2.5 / staticText < prev    next >
Encoding:
Text File  |  1994-11-06  |  1.3 KB  |  60 lines  |  [TEXT/MSET]

  1.  \ 28Oct94 dbh updated to 2.5 syntax
  2.  
  3. (*
  4.  
  5. StaticText, or non-editable text in the sense that it is not TextEdit text,
  6. is text that is meant for display only.  StaticText remembers everything it
  7. needs to draw itself including the position in the window, the font, fontsize,
  8. etc.  StaticText is also a selection class so it will follow our standard
  9. protocol.  A maximum of 16 characters will fit in a StaticText object.
  10.  
  11. Note the heavy reliance on multiple inheritance.
  12.  
  13. *)
  14.  
  15.  
  16. :class staticText super{ $16 font point+ nullselect }
  17.  
  18. :m classinit:
  19.     " Static Text" put: super> $16
  20.     50 50 moveto: super> point+ ;m
  21.  
  22. :m new:  ( wptr -- )
  23.     drop
  24.     getnew: super> font
  25.     ;m
  26.  
  27. :m draw:
  28.     get: super> point+ MoveTo    \ move graphics pen with MoveTo
  29.     set: super> font  \  must always set: the font before drawing
  30.         \ because we have no idea what the current graphport settings are
  31.     get: super> $16  mDrawString ;m
  32.  
  33. :m erase:    \ simply erases the screen display, does not change the string itself
  34.     get: mode    \ font ivar data, save on stack for subsequent restore
  35.     konst srcBic put: mode
  36.     draw: self
  37.     put: mode    \ restore mode
  38.     ;m
  39.  
  40. ;class
  41.  
  42. endload
  43.  
  44. *** EXAMPLE USE
  45.  
  46. selwindow w
  47. test: w
  48.  
  49. staticText t
  50. t add: w
  51.  
  52. staticText t2
  53. " Helvetica" fontname: t2
  54. 50 100  moveto: t2
  55. 20 fontsize: t2
  56. " Hello World" put: t2
  57. t2 add: w
  58.  
  59.  
  60.